home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 126-150 / disk_128 / wkeys / wkeys.doc < prev    next >
Text File  |  1992-05-06  |  13KB  |  287 lines

  1. OVERVIEW:
  2.  
  3. WKEYS is a program that allows you to manipulate windows through the use of 
  4. keyboard function keys rather than by using the mouse.  This way, you can
  5. activate windows, move them from front to back and vice-versa, and move
  6. screens from front to back, all without having to move your hands from the
  7. keyboard, and without having to move windows around so that you can see their
  8. depth gadgets.  It also lets you move windows or screens that do not have
  9. depth gadgets.  WKEYS knows how to perform eight different window and screen
  10. functions.  The key bindings are user definable, so you can make any key (or
  11. keys) perform any of the functions that you want.
  12.  
  13.  
  14. HOW TO USE WKEYS:
  15.  
  16. To use WKEYS, you must have WKEYS in your C: directory (or the current PATH, 
  17. and WKEYS-HANDLER in your L: directory (or the current directory).  Once this 
  18. is done, simply type:
  19.  
  20.     1> wKeys
  21.  
  22. WKEYS should display a message telling you its version number and the date it
  23. was last modified.  Once this message is displayed, the window "hot-keys" will
  24. be active.  If you wish to de-activate the hot-keys, simply issue the WKEYS
  25. command again.  WKEYS should respond by telling you that the hot-keys have
  26. been removed.
  27.  
  28. WKEYS knows how to perform the following window and screen manipulation
  29. functions:
  30.  
  31.     Next-Window           Activates the window behind the currently-active one.
  32.  
  33.     Previous-Window       Activates the window above the currently-active one.
  34.  
  35.     Window-To-Front       Moves the current window to the front of the screen.
  36.  
  37.     Window-To-Back        Moves the current window to the back of the screen.
  38.  
  39.     Screen-To-Front       Moves the back-most screen to the front and activates
  40.                           its top-most window.
  41.  
  42.     Screen-To-Back        Moves the front screen to the back and activates
  43.                           the top-most window on the screen that is revealed.
  44.  
  45.     Back-Window-To-Front  Brings the back-most window to the front and 
  46.                           activates it.
  47.  
  48.     Front-Window-To-Back  Sends the top-most window to the back and activates
  49.                           the next window down (the new top window).
  50.  
  51.  
  52. By default, these are bound to the arrow keys when you are holding down the
  53. right amiga key, or the right amiga key and the right shift key in the
  54. following manner:
  55.  
  56.     RAmiga-LeftArrow:           Previous-Window
  57.     RAmiga-RightArrow:          Next-Window
  58.     RAmiga-DownArrow:           Window-To-Back
  59.     RAmiga-UpArrow:             Window-To-Front
  60.  
  61.     RShift-RAmiga-LeftArrow:    Back-Window-To-Front
  62.     RShift-RAmiga-RightArrow:   Front-Window-To-Back
  63.     RShift-RAmiga-DownArrow:    Screen-To-Back
  64.     RShift-RAmiga-UpArrow:      Screen-To-Front
  65.  
  66. Note:  normally these keys cause the mouse pointer to move without your having 
  67. to move the mouse itself.  When the default WKEYS are in effect, however, you
  68. will have to use the LEFT amiga key (together with the arrow keys) to move the
  69. mouse pointer in this fashion.  If you prefer to use the right amiga key for 
  70. moving the pointer, you can use the WKEYS re-binding feature (see below) to
  71. change the default key bindings to something that better suits your tastes.
  72.  
  73.  
  74. CHANGING THE DEFAULT KEY BINDINGS:
  75.  
  76. Not everyone finds the default WKEYS to be optimally placed on the keyboard. 
  77. For this reason, WKEYS allows you to specify which keys should perform what
  78. functions.  To do this, you must use a key-binding file.  You tell WKEYS what 
  79. key binding file you want to use by specifying its name when you call WKEYS.
  80. For instance:
  81.  
  82.     1> wKeys Alternate.Keys
  83.  
  84. would cause WKEYS to load the key bindings that are specified in the file
  85. named "Alternate.Keys" in the current directory.
  86.  
  87. A key-binding file is a standard ASCII text file that you create using any 
  88. text editor.  Each line binds a key to a function and should have the 
  89. following form:
  90.  
  91.     qualifiers-keyname:  function
  92.  
  93. where "qualifiers" is a (possibly empty) list of key-qualifier names, 
  94. "keyname" is the name of any key on the Amiga keyboard, and "function" is
  95. one of the eight functions listed above.  For example,
  96.  
  97.     F1: Screen-To-Front
  98.     LAmiga-F1: Screen-To-Back
  99.     SHIFT-CONTROL-N: Next-Window
  100.  
  101. all are legal key bindings.
  102.  
  103. The valid qualifier names are:
  104.  
  105.     LShift          left shift key
  106.     RShift          right shift key
  107.     CapsLock        caps-lock key
  108.     Control         CTRL key
  109.     LAlt            left ALT key
  110.     RAlt            right ALT key
  111.     LAmiga          left Amiga key
  112.     RAmiga          right Amiga key
  113.     NumericPad      the key is on the numeric keypad
  114.     Repeat          the key is being auto-repeated
  115.     Interrupt       (I don't know what it means, but it's in InputEvent.h)
  116.     MultiBroadCast  (ditto)
  117.     MButton         the middle mouse button is down (future expansion)
  118.     RButton         the right mouse button is down
  119.     LButton         the left mouse button is down
  120.     RelativeMouse   (a mouse movement was relative, not absolute)
  121.  
  122.     LCommand        same as LAmiga
  123.     RCommand        same as RAmiga
  124.     Shift           either shift key
  125.     Amiga           either Amiga key
  126.     Alt             either ALT key
  127.     
  128.     KeyUp           the key is being released
  129.  
  130. Qualifiers may be separated by spaces, commas, or dashes.
  131.  
  132. The key name can be either a single, printable ASCII character (representing
  133. the key with that legend on it), or one of the following names:
  134.  
  135.     BACKSPACE, DELETE, ENTER, ESCAPE, HELP, RETURN, SPACE, TAB,
  136.     F1, F2, F3, F4, F5, F6, F7, F8, F9, F10,
  137.     KP0, KP1, KP2, KP3, KP5, KP5, KP6, KP7, KP8, KP9,
  138.     LEFTARROW, RIGHTARROW, DOWNARROW, UPARROW,
  139.     BS, DEL, ESC,  COLON, COMMA, DASH, DOT, MINUS,
  140.     CAPSLOCKKEY, CONTROLKEY, LALTKEY, LAMIGAKEY, LCOMMANDKEY, LSHIFTKEY,
  141.     RALTKEY, RCOMMANDKEY, RALTKEY, RSHIFTKEY
  142.  
  143. where "Fn" is a function key, "KPn" is a number key on the keypad, "DASH" is
  144. the dash on the main keyboard (the same key as the underscore), "DOT" is the
  145. keypad dot, and "MINUS" is the keypad minus key.  "CAPSLOCKKEY", etc. are
  146. the qualifier keys (for instance, you can make "RSHIFT-RALTKEY" map to some 
  147. function).
  148.  
  149. "COLON", "COMMA", and "DASH" are named because they are special characters
  150. within the key-binding file, and as such, can not be specified in the usual
  151. manner.
  152.  
  153. If you specify a single character name for a special symbol that requires a
  154. shift key to be pressed, the SHIFT qualifier is added automatically.  For
  155. example,  "CONTROL-*" and "CONTROL-SHIFT-*" are equivalent, as are "#" and
  156. "SHIFT-#".  Upper-case letters do not automatically include SHIFT, however.
  157. If you want an alphabetic key to require a shift key to be pressed, you must 
  158. explicitly include the SHIFT qualifier.
  159.  
  160. Note:  "NUMERICPAD-0" is NOT the same as "KP0".  The former specifies the zero
  161. key on the main keyboard with the NUMERICPAD qualifier set (a non-existant
  162. combination), whereas the latter specifies the numeric keypad zero key (with
  163. no particular qualifier keys required).
  164.  
  165. You can define as many key bindings as you want (more than one key can be
  166. bound to the same function).  Each key definition must be on its own line,
  167. however.
  168.  
  169. See the files DEFAULT.KEYS, ALTERNATE.KEYS, and STRANGE.KEYS for examples
  170. of some key binding files.
  171.  
  172.  
  173. HOW WKEYS WORKS:
  174.  
  175. WKEYS installs an input handler into the chain of handlers called by the Input
  176. Device.  This handler is added at priority 51, so it receives input events 
  177. before Intuition does.  The input handler looks at each raw-key event and 
  178. compares it to the keys defined by WKEYS.  When it finds one that is defined, 
  179. it performs the function bound to that key and removes the raw-key event from 
  180. the event list.  When all the events have been checked, it passes the 
  181. (modified) list back to the input device, which passes it to Intuition for 
  182. further processing.
  183.  
  184. When you call WKEYS, it creates an array of key bindings (either from the
  185. default bindings, or from the key-binding file that you specify).  Each key in
  186. the array takes up 8 bytes of memory.  WKEYS then calls LoadSeg() to load 
  187. WKEYS-HANDLER, which is the actual input handler, and passes it the key array.
  188. It installs WKEYS-HANDLER as an Input Device input handler, and then exits.
  189.  
  190. WKEYS uses a named, public message-port to store the address of the input
  191. handler and the key array.  When you call WKEYS a second time, it finds that
  192. public message-port and retrieves the pointers to the handler and key array,
  193. removes the handler, calles UnLoadSeg() on it, and deallocates the key array.
  194.  
  195. Since lots of keystrokes may go through the handler, and since most of those
  196. will not be one of the hot-keys, the handler must be able to determine as 
  197. quickly as possible whether a key event matches one of defined keys.  For this
  198. reason, the key array is sorted by key code and qualifiers, and is searched
  199. via a binary search method.  Thus, for example, when the eight default keys 
  200. are used, no more than three comparisons will need to be made to determine
  201. which hot-key, if any, has been pressed.  For sixteen keys, only four
  202. comparisons need be made.
  203.  
  204. HOW TO ADD YOUR OWN FUNCTIONS:
  205.  
  206. You can define your own hot-key functions by adding them into WKEYS-HANDLER.C 
  207. (just after the routine called FrontWindowToBack()).  Your routine should
  208. expect no parameters, and should return no value (i.e., it should be a
  209. function of type "void").  Your routine will be called from within the Input
  210. Handler, therefore, it should NOT call any function that might call Wait(). 
  211. This includes DOS calls, WaitIO(), LockLayers(), and all graphics primitives
  212. that could block while Layers are locked. 
  213.  
  214. Once your routine is added to the handler, include it at the end of the
  215. Action[] array in WKEYS-HANDLER.C and add a #define statement to WKEYS.H (at
  216. the bottom, just after FRONTTOBACK).  Then add an additional entry in the
  217. Action[] array in BINDWKEYS.C.  The character string is what you use within
  218. your key-binding file to specify your new function.  The code number is the
  219. number that you have #defined in WKEYS.h.  Be sure that your new entry is
  220. placed in the list so that the list remains in alphabetical order.
  221.  
  222. Once you have made these changes, you can use a key-binding file to bind keys
  223. to your new function just as though it was one of WKEYS' original functions. 
  224. You can change the default key-bindings to include your new function by
  225. following the instructions in the next section.
  226.  
  227.  
  228. HOW TO CHANGE THE DEFAULT KEY BINDINGS:
  229.  
  230. The default key-bindings are stored in an array called DefaultKey[] in the
  231. file BINDWKEYS.C.  You can change the default key setup by changing this
  232. array (you can add new keys, remove old ones, or change the keys or qualifiers
  233. used for the current default keys).  The HOTKEY() macro is used to make
  234. defining keys easy.  You specify the qualifiers first (OR them together), then
  235. the keyboard scan-code for the key, then the function number (as #defined in
  236. WKEYS.H).  The DefaultKey[] array must be sorted by KeyCode.  This means that
  237. it is sorted by scan-code first, then qualifier value.  If you are specifying
  238. qualifiers other than RAMIGA and RSHIFT, you should add them to the HOTKEY()
  239. macro #define statement.
  240.  
  241.  
  242. KNOWN PROBLEMS:
  243.  
  244. When you use the SHIFT qualifier, WKEYS really defines two key-bindings, one
  245. using LSHIFT and one using RSHIFT.  The AMIGA and ALT qualifiers produce
  246. similar results with the LAMIGA, RAMIGA, LALT, and RALT qualifiers.  Currently,
  247. you can not specify a key using more than one of these special, multi-key
  248. qualifiers (SHIFT, AMIGA, ALT).  Instead, you must explicitly define the keys
  249. in terms of LSHIFT, RSHIFT, LAMIGA, etc.  For example, SHIFT-AMIGA-N would
  250. have to be specified as LSHIFT-LAMIGA-N, LSHIFT-RAMIGA-N, RSHIFT-LAMIGA-N, and 
  251. RSHIFT-RAMIGA-N.  Note that some keyboard symbols implicity include the SHIFT
  252. qualifier, as described above ("#" is the same as "SHIFT-#").
  253.  
  254.  
  255. COMPILING AND LINKING WKEYS:
  256.  
  257. WKEYS was developed using Lattice C version 3.10.  I have tried to use longs
  258. when required by the Manx Aztec C compiler, but I do not own a copy of it,
  259. so I can not verify that WKEYS will compile properly with it.
  260.  
  261. To compile and link WKEYS, type:
  262.  
  263.     1> lc -v -r wKeys wKeys-Handler BindWKeys mSort
  264.     1> asm HandlerStub
  265.     1> blink with wKeys.lnk
  266.     1> blink with wKeys-Handler.lnk
  267.  
  268. The -v is required to suppress stack checking (since the handler will run
  269. on the Input Device's stack), but the -r is optional.
  270.  
  271. Place wKeys in your C: directory, and wKeys-Handler in your L: directory.
  272.  
  273. If you compile BindWKeys with -dNO_FILE, the file-reading code will not be
  274. included in the executable.  In this case, you will not be able to load key
  275. bindings from a file, but the program will be smaller, and will execute
  276. faster.  You can change the default key bindings as described above to make
  277. the stripped-down version load with your favorite key-bindings.
  278.  
  279.  
  280. AUTHOR:
  281.  
  282. Davide P. Cervone
  283. University of Rochester Computing Center           dpvc@tut.cc.rochester.EDU
  284. Taylor Hall                                        dpvc@ur-tut.UUCP
  285. Rochester, New York  14627                         DPVC@UORDBV.BITNET
  286. (716) 275-2811
  287.